package com.liziyi0914.morearmor.effect;

import com.liziyi0914.morearmor.Utils;
import com.liziyi0914.morearmor.event.Listener;
import com.liziyi0914.morearmor.event.entity.EntityMoveEvent;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.Items;

import java.util.function.Predicate;

/**
 * 2021/6/29<br>
 * MoreArmor<br>
 *
 * @author huanmeng_qwq
 */
public class SpiderEffect extends AbstractEffect {
    @Listener
    public void onMove(EntityMoveEvent e) {
        if (!predicateArmor().test(e.getEntity())) return;
        for (LivingEntity livingEntity : getNearEntity(e.getWorld(),e.getEntity(), 3)) {
            livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 20 * 3, 1), e.getEntity());
        }
    }

    @Override
    public Predicate<LivingEntity> predicateArmor() {
        return Utils.hasItemArmor(Items.SPIDER_EYE);
    }
}
